﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QStandardItemModel>
#include <QDir>
#include <QDebug>
#include <notes.h>
#include <QDate>
#include <QStringList>
#include <QSystemTrayIcon>
#include <QScreen>
#include <QColorDialog>
#include <sync.h>
#include <tstruct.h>
#include <QBrush>

/**
 * 作者：夜行者
***/



QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    QStandardItemModel *model;
    QString rootpath = QDir::currentPath() + "/notes";
    QString title;
    // 创建托盘图标
    QSystemTrayIcon *trayIcon = new QSystemTrayIcon(this);
    //初始化数据
    void init();
    void initBackForeg();

    //使用hash、结构体初始化数据
    QString dataFile = rootpath + "/notes.json";
    void hashInit();
    void saveHash();

    QHash <QString,QStandardItem *> qindex; //存储文件路径与项目
    QHash<QString, NoteT> hashNotes;
    QHash<QString, NoteT> *nt = &hashNotes;
    Tstruct *tt = new Tstruct;

    // 创建一个 QHash 对象，键和值都是 QString 类型
    QHash<QString, QString> textHash;
    QStringList findFilesRecursively(const QString &directory, const QString &fileName);

    //设置托盘图标
    void setTrayIcon();
    QColor backGroundColor;
    QColor fontColor;
    QColor startFontColor;

private slots:
    void on_treeView_doubleClicked(const QModelIndex &index);
    void on_pushButton_clicked();
    void sigClose();
    void on_treeView_customContextMenuRequested(const QPoint &pos);
    void on_pushButton_2_clicked();
    void on_lineEdit_textChanged(const QString &arg1);
    void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason);

    void on_pushButton_3_clicked();

    void on_pushButton_4_clicked();

    void on_pushButton_5_clicked();

    void on_pushButton_6_clicked();

    void on_pushButton_7_clicked();

    void on_pushButton_8_clicked();

    void on_pushButton_9_clicked();

    void on_pushButton_10_clicked();

private:
    Ui::MainWindow *ui;

protected:
    void closeEvent(QCloseEvent *event) override
    {
        // 当点击关闭按钮时，将窗口最小化
        this->showMinimized();
        event->ignore(); // 阻止默认关闭事件
    }

};
#endif // MAINWINDOW_H
